#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>
#include <QDateTime>
#include <QTimer>
#include <windows.h>
#include <widgets/helpdialog.h>
#include <widgets/quiwidget.h>
#include <logwindow.h>
#include <icandllheader.h>
#include <icandatatype.h>

QT_BEGIN_NAMESPACE
namespace Ui
{
    class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void scanTimer();
    void timerSlot();
    bool eventFilter(QObject *watched, QEvent *event);
    void setDI(); //函数声明,正常连接时4055输入显示DI灯
    void setDO();
    void sendDO();//DO按钮发送
    void set4017AIdata();
    void convertRangeIn4017(void);
    void on_connectButton_clicked(bool checked);

    void on_actionDisplayLog_triggered();

    void on_i4210Slider_valueChanged(int value);

    void on_i4210dSpinBox_valueChanged(double arg1);

    void on_i4210dSpinBox_1_valueChanged(double arg1);

    void on_i4210Slider_1_valueChanged(int value);

    void on_i4055ConnectButton_clicked(bool checked);

    void on_i4017ConnectButton_clicked(bool checked);

    void on_i4210ConnectButton_clicked(bool checked);

    void on_i4055Buttonqueding_clicked();

    void on_i4055ButtonDO2_clicked();

    void on_i4055ButtonDO1_clicked();

    void on_i4055ButtonDO3_clicked();

    void on_i4055ButtonDO4_clicked();

    void on_i4055ButtonDO5_clicked();

    void on_i4055ButtonDO6_clicked();

    void on_i4055ButtonDO7_clicked();

    void on_i4055ButtonDO8_clicked();

    void on_i4210ButtonReset_clicked();

    void on_i4210ButtonSureout_clicked();

    void on_actionAboutCANTest_triggered();

    void on_i4017resetbutton_clicked();

signals:
    void logToLog(QString str);

private:
    Ui::MainWindow *ui;

    QTimer *mTimer;
    QTimer *mPlotTimer;
    float connectTime;
    float plotTime;

    LogWindow *mLogWindow;
    QUIWidget quiLog;

    ROUTECFG masterCfg;
    HANDLE hRoute = 0;
    I4055_t slave4055;
    I4017_t slave4017;
    I4210_t slave4210;
    virtualSlave_t slaveVirtual;

    QVector<double> xAxis;
    QVector<double> yCh0;
    QVector<double> yCh1;

    bool virtualConnection = false;
};
#endif // MAINWINDOW_H
